﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HeresyManager.Traits
{
    [Serializable]
    public class SupremelyConnected : Trait
    {
        public override string Name
        {
            get { return "Supremely Connected"; }
        }

        Talent[] talents;


        public override IEnumerator<Comunication.Comunicator> Accire(Character c)
        {
            var e = base.Accire(c);
            while (e.MoveNext())
                yield return e.Current;

            var com = new Comunication.ChoseTalentFromType("Selecting one category to reflect your family’s powerbase", c, typeof(Talents.Peer));
            if (com.Posebilitys.Length != 0)
            {
                while (com.SelectedValue == null)
                    yield return com;
                talents = new Talent[] { new Talents.Peers.PeerNobility(), com.SelectedValue };
            }
            else
                talents = new Talent[] { new Talents.Peers.PeerNobility() };

            foreach (var s in talents)
            {
                e = c.AddTalent(s, this);
                while (e.MoveNext())
                    yield return e.Current;
            }
        }

        public override void DeAccire(Character c)
        {
            base.DeAccire(c);
            foreach (var s in talents)
            {
                c.RemoveTalent(s, this);
            }
        }
    }
}
